/*
 * Copyright (C) 2015 yixun All Rights Reserved.
 * 
 * CustomerPremisesMapper.java
 */
package com.yixun.qfbao.xf.mapper;

import com.yixun.qfbao.model.*;
import com.yixun.qfbao.model.dto.HouseSalePerformanceDto;
import com.yixun.qfbao.model.dto.OrganSalePerformanceDto;
import com.yixun.qfbao.model.initdto.InitCPCustomerDto;
import com.yixun.qfbao.model.whdto.ItemInfoDto;
import com.yixun.qfbao.xf.model.CustomerPremises;
import com.yixun.qfbao.xf.model.dto.CustomerPremisesDto;
import com.yixun.qfbao.xf.model.dto.CustomerPremisesVisitCountDto;
import com.yixun.qfbao.xf.model.dto.SendIntentionListResultDto;
import com.yixun.qfbao.xf.model.dto.SendVisitListResultDto;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * [文件名称]<br>
 * CustomerPremisesMapper.java<br>
 * <br>
 * [文件描述]<br>
 * 客户报备信息 mapper<br>
 * <br>
 * [修改记录]<br>
 * 2015-10-14 15:34:13 创建 陶俊代码生成器<br>
 * 
 * @author 陶俊代码生成器
 * @version 1.00
 */
public interface CustomerPremisesMapper {

	/**
	 * 新增
	 *
	 * @param customerPremises
	 *            新增BEAN信息
	 * @return 操作行数
	 */
	public int add(CustomerPremises customerPremises);

	/**
	 * 删除
	 *
	 * @param customerPremisesDto
	 *            满足删除的条件
	 * @return 操作行数
	 */
	public int del(CustomerPremisesDto customerPremisesDto);

	/**
	 * 删除
	 *
	 * @param ids
	 *            待删除的唯一主键拼接的字符串,主键间以,隔开
	 * @return 操作行数
	 */
	public int dels(String ids);

	/**
	 * 编辑
	 *
	 * @param customerPremises
	 *            需要编辑的BEAN信息
	 */
	public int edit(CustomerPremises customerPremises);

	int updateCustomerByCustomerIds(CustomerPremisesDto customerPremisesDto);

	/**
	 * 编辑
	 *
	 * @param customerPremises
	 *            需要编辑的BEAN信息
	 * @param ids
	 *            待编辑的唯一主键拼接的字符串,主键间以,隔开
	 * @return 更新行数
	 */
	public int edits(@Param("customerPremisesDto") CustomerPremises customerPremises, @Param("ids") String ids);

	/**
	 * 搜索总数
	 *
	 * @param customerPremisesDto
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int count(CustomerPremisesDto customerPremisesDto);

	public int overTradeTimeCount(CustomerPremisesDto entity);
	/**
	 * 搜索总数
	 *
	 * @param customerPremisesDto
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int myCount(CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索总数
	 *
	 * @param customerPremisesDto
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int countDto(CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索 - 支持分页
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @param beginNum
	 *            分页开始页不包含
	 * @param endNum
	 *            分页结束页不包含
	 * @return 分页数据
	 */
	public List<CustomerPremises> list(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,
			@Param("beginNum") int beginNum, @Param("endNum") int endNum);
	/**
	 * 搜索 - 支持分页
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @param beginNum
	 *            分页开始页不包含
	 * @param endNum
	 *            分页结束页不包含
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> myList(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,
			@Param("beginNum") int beginNum, @Param("endNum") int endNum);

	/**
	 * 搜索 - 支持分页 功能描述: <br>
	 * 〈功能详细描述〉
	 *
	 * @param customerPremisesDto
	 * @param beginNum
	 * @param endNum
	 * @return
	 * @see [相关类/方法](可选)
	 * @since [产品/模块版本](可选)
	 */
	public List<CustomerPremisesDto> listDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,
			@Param("beginNum") int beginNum, @Param("endNum") int endNum);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremises> selectListByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索 - 支持分页
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public CustomerPremises selectByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * @param id
	 * @return 根据id查询记录
	 */
	public CustomerPremises selectById(@Param("id") Long id);
	/**
	 * @param id
	 * @return 根据id查询记录
	 */
	public CustomerPremisesDto selectByMyId(@Param("id") Long id);

	public Integer selectByCompanyId(@Param("staffCompanyId") Long saffCompanyId, @Param("status") String status, @Param("staffId")Long staffId);

	public BigDecimal sumTotal(@Param("staffCompanyId") Long saffCompanyId, @Param("staffId")Long staffId);


	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremises> findCustomerListByStaffId(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> selectRecommendCusByPremises(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> selectAdminRecommendCusByPremises(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	//经纪人排行查询
	public List<AgentRank> queryAgentRankReport(@Param("agentRankReportParam")AgentRankReportParam agentRankReportParam);
	//经纪人排行查询
	public List<AgentRank> queryAgentRankReportByfollow(@Param("agentRankReportParam")AgentRankReportParam agentRankReportParam);
	//经纪人排行查询(优化)
	public List<AgentRankReport> queryAgentRankReportByCompanyId(@Param("agentRankReportParam")AgentRankReportParam agentRankReportParam,@Param("begin")int begin,@Param("end")int end);
	//经纪人排行查询(优化)
	public int countAgentRankReportByCompanyId(@Param("agentRankReportParam")AgentRankReportParam agentRankReportParam);

	//客户推荐转化查询
	public List<CustomerConversionReport> queryCustomerConversionReport(@Param("customerConversionReportParam")CustomerConversionReportParam customerConversionReportParam,@Param("begin") int begin,@Param("end")int end);
	//客户推荐转化查询
	public int countCustomerConversionReport(@Param("customerConversionReportParam")CustomerConversionReportParam customerConversionReportParam);

	//渠道效果分析查询
	public List<ChannelEffectReport> queryChannelEffectReport(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam);
	//渠道效果分析查询
	public List<ChannelEffectReport> queryAllChannelEffectReport(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam,@Param("begin")int begin,@Param("end")int end);
	//机构门店业绩分析
	List<ChannelEffectReport> queryStoreReport(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam,@Param("begin")int begin,@Param("end")int end);
	int queryStoreReportCount(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam);
	//组别业绩分析
	List<ChannelEffectReport> selectGroupReport(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam,@Param("begin")int begin,@Param("end")int end);
	int selectGroupReportCount(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam);
	//经纪人业绩分析
	List<ChannelEffectReport> selectAgentReport(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam,@Param("begin")int begin,@Param("end")int end);
	int selectAgentReportCount(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam);
	public int countAllChannelEffectReport(@Param("channelEffectReport")ChannelEffectReportParam channelEffectReportParam);
	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> selectCustomerByPremises(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 待处理申述搜索总数
	 *
	 * @param customerPremisesDto
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int appealCount(CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索 - 支持分页 功能描述: <br>
	 * 待处理申诉
	 *
	 * @param customerPremisesDto
	 * @param beginNum
	 * @param endNum
	 * @return
	 * @see [相关类/方法](可选)
	 * @since [产品/模块版本](可选)
	 */
	public List<CustomerPremisesDto> appealList(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,
			@Param("beginNum") int beginNum, @Param("endNum") int endNum);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> selectCommissionByPremises(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> selectCustomerByDay(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> selectDtoListByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremises> selectListByIds(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索总数
	 *
	 * @param customerPremisesDto
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int updateByIds(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);
	/**
	 *
	 * @param staffId 经纪人id
	 * @return
	 */
	public Long getPricipalId(@Param("staffId")Long staffId);
	/**
	 * 分销佣金机构列表数据
	* @Title: CustomerPremisesMapper
	* @Description: TODO
	* @param customerPremisesDto
	* @param beginNum
	* @param endNum
	* @return
	* @author guifang.weng
	* @date 2017年10月24日 下午4:50:33
	 */
	public List<CustomerPremisesDto> selectDisCompanyList(
			@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,@Param("beginNum") int beginNum, @Param("endNum") int endNum);
	/**
	 * 分销佣金机构列表数据记录数
	* @Title: CustomerPremisesMapper
	* @Description: TODO
	* @param customerPremisesDto
	* @return
	* @author guifang.weng
	* @date 2017年10月24日 下午4:52:51
	 */
	public Integer selectDisCompanyCount(CustomerPremisesDto customerPremisesDto);
	/**
	 * 获取待结算佣金总额
	* @Title: CustomerPremisesMapper
	* @Description: TODO
	* @param customerPremisesDto
	* @return
	* @author guifang.weng
	* @date 2017年10月25日 下午5:39:53
	 */
	public CustomerPremisesDto getPendCommissionAmount(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);
	/**
	 * 获取机构佣金详情
	 *@author xiaojin.li
	 *@date 2017年10月24日下午1:21:35
	 *@param customerPremisesDto
	 *@return
	 */
	public List<CustomerPremisesDto> getSettlementRecord(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);
	/**
	 * 获取机构佣金详情汇总数据
	 *@author xiaojin.li
	 *@date 2017年10月25日下午2:19:22
	 *@return
	 */
	public CustomerPremisesDto getCommissionDetail(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);
	/**
	 * 机构佣金明细数据
	 *@author xiaojin.li
	 *@date 2017年10月25日下午4:05:26
	 *@param customerPremisesDto
	 *@return
	 */
	public List<CustomerPremisesDto> getCooCommissionDetail(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);

	/**
	 * 查询成交总金额
	 * @param customerPremisesDto
	 * @return BigDecimal
	 * @author shaoping.jiao
	 */
	public BigDecimal queryDealTotalAmount(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);

	/**
	 * 查询成交总套数
	 * @param customerPremisesDto
	 * @return int
	 * @author shaoping.jiao
	 */
	public int queryDealTotalNumber(@Param("customerPremisesDto")CustomerPremisesDto customerPremisesDto);

	/**
	 * 搜索总数
	 *
	 * @param commissionId
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int myCommissionCount(@Param("commissionId")Long commissionId);

	/**
	 * 搜索 - 支持分页
	 *
	 * @param commissionId
	 *            blackWhiteList(搜索条件)
	 * @param beginNum
	 *            分页开始页不包含
	 * @param endNum
	 *            分页结束页不包含
	 * @return 分页数据
	 */
	public List<CustomerPremisesDto> myCommissionList(@Param("commissionId")Long commissionId,
			@Param("beginNum") int beginNum, @Param("endNum") int endNum);
	/**
	 * 搜索
	 *
	 * @param customerPremisesDto
	 *            blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<CustomerPremises> selectMyListByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,@Param("beginNum")int beginBum,@Param("endNum")int endNum);

	/**
	 *
	 * @param id
	 * @return
	 */
	CustomerPremises selectByIdForLock(@Param("id") Long id);


	/**
	 * 更新首付金信息
	 *
	 * @param customerPremises
	 *            需要编辑的BEAN信息
	 */
	int updateFirstPayment(CustomerPremises customerPremises);

	/**
	 * 超过到访保护时间然后做处理
	 * @return
	 */
	List<CustomerPremisesDto> selectCPForVisitJob();

    List<CustomerPremisesDto> seleceCPList(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,
                                           @Param("beginNum") int beginNum, @Param("endNum") int endNum);

    Integer seleceCPCountList(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    List<HouseSalePerformanceDto> houseSalePerformancePageList(@Param("param")Map<String, Object> param, @Param("beginNum") int beginNum, @Param("endNum") int endNum);

    int houseSalePerformancePageCount(@Param("param")Map<String, Object> param);

    List<OrganSalePerformanceDto> organSalePerformancePageList(@Param("param")Map<String, Object> param, @Param("beginNum") int beginNum, @Param("endNum") int endNum);

    int organSalePerformancePageCount(@Param("param")Map<String, Object> param);

    int queryValidReportCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    int queryPayDepositCountCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    int querySubscribeTotalCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    int queryValidVisitCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    int querySignCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	BigDecimal querySignAmountCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    List<CustomerPremisesDto> selectForCheckRepeatByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    CustomerPremisesDto selectCompanyByCpId(@Param("id") Long id);

    CustomerPremises selectResetNode(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

    List<CustomerPremisesDto> selectImportRepeatListByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	List<CustomerPremisesVisitCountDto> visitCount(@Param("customerPremisesIds") List<Long> customerPremisesIds);

	/**
	 * 根据渠道公司id及当前日期按楼盘导出业务情况
	 *
	 * @param reqDto
	 * @return
	 */
	List<DevPremisesExport> getDevPremisesInfoByPre(@Param("reqDto") CustomerPremisesDto reqDto,@Param("begin") Integer begin,@Param("size") Integer size);

	/**
	 * 根据渠道公司id及当前日期按推荐人导出业务情况
	 *
	 * @param reqDto
	 * @return
	 */
	List<DevPremisesExport> getDevPremisesInfoByRec(@Param("reqDto") CustomerPremisesDto reqDto,@Param("begin") Integer begin,@Param("size") Integer size);

	List<DevPremisesExport> getDevPremisesExportByRec(@Param("reqDto") CustomerPremisesDto customerPremisesDto);

	List<DevPremisesExport> getDevPremisesExportByPre(@Param("reqDto") CustomerPremisesDto customerPremisesDto);

	int getDevPremisesCountByRec(@Param("reqDto") CustomerPremisesDto customerPremisesDto);

	int getDevPremisesCountByPre(@Param("reqDto") CustomerPremisesDto customerPremisesDto);

	List<VisitStateInfo> getVisitStateList(@Param("reqDto") CustomerPremisesDto entity);

	int changeCPAdviser( @Param("premisesId") Long premisesId,  @Param("customerPremisesId") Long customerPremisesId, @Param("oldAdviser") String oldAdviser, @Param("newAdviser") String newAdviser);

	List<Long> selectPremisesIdsByStaffIds(@Param("staffIds") List<List<Long>> staffIds);

	/**
	 * 获取即将无效的消息
	 * @return
	 */
	List<Map<String, Object>> getToBeDueRemainderInfo(Map<String, Object> params);

	/**
	 * 获取已经无效的消息
	 * @return
	 */
	List<Map<String, Object>> getDueRemainderInfo(Map<String, Object> params);

	/**
	 * 根据ID和remainderType，add状态变更提醒次数
	 * @param dueRemainderInfos
	 * @return
	 */
	int addSendTimesById(List<Map<String, Object>> dueRemainderInfos);

	int resetConfirm(CustomerPremisesDto customerPremisesDto);

	/**
	 *  查询报备信息，增加佣金信息
	 * @param customerPremisesDto
	 * @return
	 */
	public CustomerPremises selectcCustomerPremisesCommissionByDto(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	List<ItemInfoDto> selectWHSyncReportList(@Param("reqDto") CustomerPremisesDto entity);

	/**
	 *  报备列表--小程序使用
	 * @param customerPremisesDto
	 * @param beginNum
	 * @param endNum
	 * @return
	 */
	public List<CustomerPremisesDto> selectCPForWeappList(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto,
											@Param("beginNum") int beginNum, @Param("endNum") int endNum);

	/**
	 * 报备搜索总数 --小程序使用
	 *
	 * @param customerPremisesDto
	 *            搜索条件
	 * @return 符合条件记录总数
	 */
	public int selectCPForWeappCount(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	List<InitCPCustomerDto> selectInitCPCustomerList(@Param("customerPremisesDto") CustomerPremisesDto customerPremisesDto);

	/**
	 * 定时推送 到访数据查询
	 * @param lastTime
	 * @param companyId
	 * @return
	 */
	List<SendVisitListResultDto> getSendVisitList(@Param("lastTime")String lastTime, @Param("companyId")Long companyId);

	/**
	 * 定时推送 报备信息查询
	 * @param lastTime
	 * @param companyId
	 * @return
	 */
	List<SendIntentionListResultDto> getSendIntentionList(@Param("lastTime")String lastTime, @Param("companyId")Long companyId);



	/**
	 * @param mobile
	 * @return 根据mobile查询记录
	 */
	public CustomerPremises selectByMobile(@Param("mobile") String mobile);
}

